package com.xuzao.developer.tools.base;

import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 基础service
 *
 * @author lulei
 * @version v1.0
 * @date 2018年2月22日 下午4:42:17
 */


public abstract class BaseServiceSupport<T> implements BaseService<T> {
    @Autowired
    protected Mapper<T> mapper;

    @Override
    public T selectOne(T entity) {
        return mapper.selectOne(entity);
    }

    @Override
    public T selectById(Object id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public List<T> selectList(T entity) {
        return mapper.select(entity);
    }

    @Override
    public List<T> selectListAll() {
        return mapper.selectAll();
    }

    @Override
    public Long selectCount(T entity) {
        return new Long(mapper.selectCount(entity));
    }

    @Override
    public Integer insert(T entity) {
        return mapper.insert(entity);
    }

    @Override
    public Integer insertSelective(T entity) {
        return mapper.insertSelective(entity);
    }

    @Override
    public Integer delete(T entity) {
        return mapper.delete(entity);
    }

    @Override
    public Integer deleteById(Object id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public Integer updateById(T entity) {
        return mapper.updateByPrimaryKey(entity);
    }

    @Override
    public Integer updateSelectiveById(T entity) {
        return mapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public List<T> selectByExample(Object example) {
        return mapper.selectByExample(example);
    }

    @Override
    public Integer selectCountByExample(Object example) {
        return mapper.selectCountByExample(example);
    }

    @Override
    public Integer updateByExampleSelective(T entity, Object example) {
        return mapper.updateByExampleSelective(entity, example);
    }

}
